<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>麦米思平台</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1, maximum-scale=1"
    />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <link rel="icon" type="image/png" th:href="@{${contextPath}+'/amis/public/logo.png'}">
    <link
      rel="stylesheet"
      title="default"
      th:href="@{${contextPath}+'/amis/sdk/antd.css'}"
    />
    <link
      rel="stylesheet"
      th:href="@{${contextPath}+'/amis/sdk/helper.css'}"
    />
    <script th:src="@{${contextPath}+'/amis/sdk/sdk.js'}"></script>
    <!-- <script src="https://unpkg.com/vue@2"></script>
    <script th:src="@{${contextPath}+'/amis/lib/history/history.js'}"></script> -->
    <script th:src="@{${contextPath}+${js}}"></script>
    <style>
      html,
      body,
      .app-wrapper {
        position: relative;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="root" class="app-wrapper"></div>
    <script>
      const __mamis__contextPath = '[[${contextPath}]]';
      const __mamis__sysCode = '[[${sysCode}]]';
      (function () {
        let amis = amisRequire('amis/embed');
        
        let amisInstance = amis.embed(
          '#root',
          {
            ...amisJSON,
            "data": { ...amisJSON.data, __mamis__contextPath, __mamis__sysCode }
          },
          {},
          {
            requestAdaptor (api) {
              if (api.url.startsWith('//') ||
                 !api.url.startsWith('/') ||
                  api.url === __mamis__contextPath) {
                return api;
              }
              return {...api, url: __mamis__contextPath + api.url, headers: {...api.headers, 'mamis-sys-code': __mamis__sysCode } };
            },
            theme: 'antd'
          }
        );
      })();
    </script>
  </body>
</html>
